package org.example.erp.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.erp.domain.Warehouse;
import org.example.erp.domain.WarehouseArea;
import org.example.erp.mapper.WarehouseAreaMapper;
import org.example.erp.service.WarehouseService;
import org.example.erp.mapper.WarehouseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.example.erp.utils.WarehouseTreeBuild;

import java.util.List;

import static org.example.erp.utils.WarehouseTreeBuild.TreeNode.buildTree;

/**
* @author 86180
* @description 针对表【warehouse(仓库管理表)】的数据库操作Service实现
* @createDate 2024-11-21 10:27:36
*/
@Service
public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper, Warehouse>
    implements WarehouseService{
    @Autowired
    private WarehouseMapper warehouseMapper;


    public IPage<Warehouse> findwarehouse(
                                    Integer currentPage,
                                   Integer pageSize,
                                   String warehouseCode,
                                   String warehouseName
                                   ) {
        Page<Warehouse> page=new Page<>(currentPage,pageSize);
        return warehouseMapper.findwarehouse(page,warehouseCode, warehouseName);
    }


    public List<WarehouseTreeBuild.TreeNode> findwarehousearea(){
        List<Warehouse> warehouses = warehouseMapper.findwarehousearea();
        List<WarehouseTreeBuild.TreeNode> treeNodes = buildTree(warehouses);
        return treeNodes;
//        return warehouseMapper.findwarehousearea();
    }



}




